package com.hontech.kaltaapp.ui.parts

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.kaltaapp.R
import com.hontech.kaltaapp.device.drawWater
import com.hontech.kaltaapp.ui.dialog.runProg
import com.hontech.kaltaapp.ui.view.LabelInput
import com.hontech.kaltaapp.utils.onClick

class NozzleWaterParts (context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_nozzle_water, this)
        val btn = view.findViewById<Button>(R.id.id_water_btn_ctrl)
        val mm = view.findViewById<LabelInput>(R.id.id_water_mm)
        val temp = view.findViewById<LabelInput>(R.id.id_water_temp)
        val ml = view.findViewById<LabelInput>(R.id.id_water_ml)
        btn.onClick {
            runProg("喷嘴放水", "放水") {
                drawWater(mm.textInt(), temp.textInt(), ml.textInt())
            }
        }
    }
}